/**
 * @description  : 审批通过页面
 * @descriptionDetail : 审批通过页面
 * @copyright    : 浙江烟草
 * @author       : mc
 * @create       : 2022-11-05 09:47:30
 */
<template>
  <view class="page">
    <!-- #ifdef H5-ONLY -->
    <theme-navbar :is-white="false" :title="navTitle" :custom-back="goBack" style="z-index: 99999">
    </theme-navbar>
    <!-- #endif -->
    <view class="content u-page">
      <view class="lay-root">
        <view class="lay-content">
          <u-radio-group v-model="isAgree" @change="change">
            <u-radio :name="item.value" v-for="(item, index) in list" :key="index">
              {{ item.name }}
            </u-radio>
          </u-radio-group>
        </view>
      </view>
      <u-line :color="$theme.u_border_color"></u-line>
      <view class="lay-root">
        <u-input type="textarea" placeholder="请输入审批意见" v-model="remark"></u-input>
      </view>
      <u-line :color="$theme.u_border_color"></u-line>
    </view>

    <view class="btm-lay">
      <u-button plain size="default" type="error" @click="resetData()">
        重置
      </u-button>
      <u-button size="default" type="primary" @click="confirmBack()">
        确认
      </u-button>
    </view>
  </view>
</template>

<script>
export default {
  onLoad() {
    let op = this.getRouteParam();
    this.comments = op.comments;
    this.currStep = op.currStep;
    this.gfcode = op.gfcode;
    this.parent = op.parent;
    this.docData = op.docData;
  },
  data() {
    return {
      comments: undefined,
      currStep: "",
      parent:'',
      gfcode:'',
      docData:{},
      list: [],
      remark: "",
      isAgree: "",
    }
  },
  mounted() {
    if(this.comments && this.comments.length > 0) {
      this.list = [...this.comments,];
    } else if (this.currStep == 'audit') {
      this.list = [{
        name: '建议许可',
        value: "1",
      },
      {
        name: '建议不予许可',
        value: "0",
      },
      ];
    } else if (this.currStep == 'approval') {
      this.list = [{
        name: '准予许可',
        value: "1",
      },
      {
        name: '不予许可',
        value: "0",
      },
      ];
    } else if (this.currStep == '01') {
      this.list = [{
        name: '准予更正',
        value: "1",
      },
      {
        name: '不准予更正',
        value: "0",
      },
      ];
    }
  },
  methods: {
    resetData() {
      this.isAgree = "";
      this.remark = "";
    },
    change(e) {
      let name = "";
      for (let i = 0; i < this.list.length; i++) {
        if (this.list[i].value == e) {
          name = this.list[i].name;  
          break;
        }
      }
      this.remark = name;
    },
    confirmBack() {
      if (this.$u.test.isEmpty(this.isAgree)) {
        this.$modal.alert("请选择是否许可");
        return;
      }
      if (this.$u.test.isEmpty(this.remark)) {
        this.$modal.alert("请输入审批意见");
        return;
      }
      let ox = this.isAgree == '1' ? true : false;
      if(this.docData['reviewResult'] != ox && this.parent == 'lic' && this.gfcode == 'licapproval2'){
        this.$modal.alert("审批与审查意见不同,请退回修改");
        return;
      }
      this.backPrev({
        paramKey: "auditApprove",
        param: {
          isAgree: this.isAgree,
          remark: this.remark,
        },
      });
    },
  },
}
</script>

<style scoped lang="scss">
	.content {
		background-color: #FFF;
	}

	.lay-root {
		width: 100%;
		padding: 40rpx 30rpx;
		display: inline-flex;
		flex-direction: row;
		justify-content: space-between;
	}

	.lay-title {
		align-self: center;
		flex-shrink: 0;
		font-size: 32rpx;
	}

	.lay-content {}

	.btm-lay {
		display: flex;
		flex-direction: row;
		position: fixed;
		bottom: 0;
		width: 100%;
		padding: 20rpx 0;
	}

	/deep/uni-button {
		width: 40%;
	}
</style>
